import request from '@/utils/request'

// 查询培训课件列表
export function listCourse_ware(query) {
    return request({
        url: '/course/course_ware/list',
        method: 'get',
        params: query
    })
}

// 查询培训课件详细
export function getCourse_ware(id) {
    return request({
        url: '/course/course_ware/' + id,
        method: 'get'
    })
}

// 新增培训课件
export function addCourse_ware(data) {
    return request({
        url: '/course/course_ware',
        method: 'post',
        data: data
    })
}

// 新增培训课件
export function upload(file) {
  //组装参数
  let form = new FormData();
  form.append("file",file.raw)
  return request({
    url: '/course/course_ware/upload',
    timeout: 1000 * 60 * 10,
    method: 'post',
    data: form,
    headers: {"Content-Type": "multipart/form-data; charset=utf-8"},
    contentType: false,
    processData: false,
    withCredentials: false
  })
}

// 修改培训课件
export function updateCourse_ware(data) {
    return request({
        url: '/course/course_ware',
        method: 'put',
        data: data
    })
}

//添加课件的题目
export function addWareQuestion(question,wareId){
  return request({
    url: '/course/course_ware/question/' + wareId,
    method: 'post',
    data: question
  })
}
//新增评论
export function addWareComment(wareId,content){
  var body = {wareId:wareId,content:content}
  return request({
    url: '/course/course_ware/comment',
    method: 'post',
    data: body
  })
}

// 删除培训课件的题目
export function delCourseWareQuestion(wareId,questionId) {
  return request({
    url: '/course/course_ware/question/' + wareId + '/' + questionId,
    method: 'delete'
  })
}

// 删除培训课件
export function delCourse_ware(id) {
    return request({
        url: '/course/course_ware/' + id,
        method: 'delete'
    })
}
